package com.rtline.business.enums;

import com.rtline.business.vo.OrderVo;
import com.rtline.business.vo.UserVo;

/**
 * <p>ServiceType .
 *
 * <p>change history:
 *
 * <pre>
 * date         defect       person          comments
 * --------------------------------------------------------------------------------
 * 2025/6/3    ********     Tao Ren    create file.
 * </pre>
 *
 * @author Tao Ren
 * @date 2025/6/3 19:20
 */

public enum ServiceType {
    USER("user", "userServiceImpl", UserVo.class),
    ORDER("order", "orderServiceImpl", OrderVo.class);

    private final String key;
    private final String beanName;
    private final Class<?> clazz;

    ServiceType(String key, String beanName, Class<?> clazz) {
        this.key = key;
        this.beanName = beanName;
        this.clazz = clazz;
    }

    public static ServiceType getByKey(String key) {
        for (ServiceType serviceType : ServiceType.values()) {
            if (serviceType.getKey().equals(key)) {
                return serviceType;
            }
        }
        throw new IllegalArgumentException("Invalid key: " + key);
    }

    public String getKey() {
        return key;
    }

    public String getBeanName() {
        return beanName;
    }

    public Class<?> getClazz() {
        return clazz;
    }
}
